package br.ita.doacoes.view.cadastrodoacoes;

import java.util.List;

import javax.swing.DefaultComboBoxModel;

import br.ita.doacoes.core.cadastrodoacoes.dao.ContraparteDAO;
import br.ita.doacoes.core.cadastrodoacoes.dao.impl.ContraparteDAOImpl;
import br.ita.doacoes.domain.cadastrodoacoes.Contraparte;
import br.ita.doacoes.view.cadastrodoacoes.refresher.Refreshable;
import br.ita.doacoes.view.cadastrodoacoes.refresher.Refresher;

public class ContraparteCombo extends DefaultComboBoxModel implements
		Refreshable {
	ContraparteDAO dao;

	public ContraparteCombo() {
		dao = new ContraparteDAOImpl(Contraparte.class);
		refresh();
		Refresher.add(this);
	}

	public void refresh() {
		List lista = dao.getList();
		removeAllElements();
		for (Object obj : lista) {
			addElement(obj);
		}
	}
}
